package com.xiangyi.teachingsystem.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiangyi.teachingsystem.entity.dto.MessageDto;
import com.xiangyi.teachingsystem.entity.po.Message;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MessageMapper extends BaseMapper<Message> {

    @Select("SELECT m.group_id,m.msg,m.msg_time,u.`name`\n" +
            "FROM message m\n" +
            "LEFT JOIN `user` u\n" +
            "ON m.user_id=u.id\n" +
            "WHERE m.group_id=#{groupId}")
    List<Message> list(Integer groupId);

    @Select("SELECT m.msg,m.msg_time,u.`name`,u.head_url,m.user_id\n" +
            "FROM message m\n" +
            "LEFT JOIN `user` u\n" +
            "ON u.id=m.user_id\n" +
            "WHERE m.group_id=#{groupId}")
    List<MessageDto> infoList(Integer groupId);
}
